var util = require('../../utils/util.js');
var utilMd5 = require('../../utils/md5.js');
var WxParse = require('../../wxParse/wxParse.js');
var app = getApp();
var wxAuthFail = true; 
var inviteuid = 0;

Page({
  data: {
    util: util,
    tc: 0,

    isIphone_x: false,
    nav_bgColor: '#ffffff',
    
    uid: 0,
    
    tx:"",

    aboutMessage: ''
  },
  onLoad: function(data){
    
    var that = this;
    var tc = app.get_tc();//简体繁体转换
    console.log("tc======",tc);
    that.setData({
      tc: tc,
    });
    inviteuid = data.inviteuid ? data.inviteuid : '';
    
    //获取颜色配置
    app.getColorSetData(function (color) {
      that.setData({
        colorSet: color,
      })
      that.resetNavColor();
    });


    wx.getSystemInfo({
      success: function(res) {
        var isIphone_x = (res.model.indexOf('iPhone X') >= 0);
        that.setData({
          isIphone_x: isIphone_x,
          screen_h: res.windowHeight,
        });
      }
    });
    var titleName = tc == 1 ? '帮助' : '帮助';

    wx.setNavigationBarTitle({
      title: titleName,
    })

    app.getAllAbout('shouhou', function (res) {
      that.setData({
        aboutMessage: res
      });
      /** 
        * WxParse.wxParse(bindName , type, data, target,imagePadding) 
        * 1.bindName绑定的数据名(必填) 
        * 2.type可以为html或者md(必填) 
        * 3.data为传入的具体数据(必填) 
        * 4.target为Page对象,一般为this(必填) 
        * 5.imagePadding为当图片自适应是左右的单一padding(默认为0,可选) 
        */
      WxParse.wxParse('aboutMessage', 'html', that.data.aboutMessage, that, 12);
    });
  },
  onShow:function(){
    
  },

  //保存formId
  submitFormId: function (e) {
    app.saveFormId(e.detail.formId);
    var path = e.detail.value.nav_path;
    if (path && path.indexOf('navto:') == 0) {
      path = path.slice(6);
    }
    wx.reLaunch({
      url: path,
    })
  },

  resetNavColor: function () {
    var bg_color = '#d8202d';
    var fg_color = '#ffffff';
    if (this.data.colorSet) {
      var colorJO = this.data.colorSet;
      bg_color = colorJO.titlebg;
      fg_color = colorJO.titlefont;
    }
    wx.setNavigationBarColor({
      frontColor: fg_color,
      backgroundColor: bg_color
    });
    this.setData({
      frontColor: fg_color,
      backgroundColor: bg_color
    })
  }

})